package front

import (
	"net/http"
	"strconv"
	"time"
	"tmall_go/models"

	"github.com/gin-gonic/gin"
)

type GoodsController struct{}

func (con GoodsController) Detail(c *gin.Context) {
	currentTime := time.Now().Format("2006-01-02 15:04:05")
	idStr := c.Query("id")
	idNum, _ := strconv.Atoi(idStr)
	goods := models.Goods{}
	models.DB.Where("id=?", idNum).Find(&goods)
	c.HTML(http.StatusOK, "frontdesk/goodsInfo.html", gin.H{
		"currentTime": currentTime,
		"info":        goods,
	})
}
